/*
 * @Author: likaijie 847094299@qq.com
 * @Date: 2025-04-07 09:23:14
 * @LastEditors: likaijie 847094299@qq.com
 * @LastEditTime: 2025-04-07 12:51:32
 * @Description:
 */
import { http } from "@/utils/http";

/**
 * 获取所有标准列
 */
export const getAllColumnStandards = (params?: {
  keyword?: string;
  onlyEnabled?: boolean | string;
  page: number;
  size: number;
}) => {
  return http.request<any>("get", "/api/admin/column-standards", { params });
};

/**
 * 创建标准列
 */
export const createColumnStandards = (data: {
  columnType?: string;
  standardName?: string;
  description?: string;
  sortOrder?: string | number;
  enabled?: boolean;
}) => {
  return http.request<any>("post", "/api/admin/column-standards", {
    data,
    headers: { "Content-Type": "application/x-www-form-urlencoded" }
  });
};
/**
 * 更新标准列
 */
export const updateColumnStandards = (data: {
  id?: number | string;
  columnType?: string;
  standardName?: string;
  description?: string;
  sortOrder?: string | number;
  enabled?: boolean;
}) => {
  return http.request<any>("put", `/api/admin/column-standards/${data.id}`, {
    data,
    headers: { "Content-Type": "application/x-www-form-urlencoded" }
  });
};

/**
 * 获取标准列映射列ids
 */
export const getMappingIds = (id: number) => {
  return http.request<any>(
    "get",
    `/api/admin/column-standards/${id}/mapping-ids`
  );
};

/**
 * 更新标准列映射列ids
 */
export const putMappingIds = (
  id: number,
  data: {
    mappingIds?: number[] | string[];
  }
) => {
  return http.request<any>(
    "put",
    `/api/admin/column-standards/${id}/mapping-ids`,
    {
      data
    }
  );
};

/**
 * 删除标准列
 */
export const deleteColumnwStandards = (id: number) => {
  return http.request<any>("delete", `/api/admin/column-standards/${id}`);
};
